wifi.startsmart(
    0,
    function(ssid, password)
        print(string.format("Success:%s,%s", ssid, password))
        wifi.sta.connect()
        local mytimer = tmr.create()
        mytimer:register(
            1000,
            tmr.ALARM_AUTO,
            function(t)
                local ip = wifi.sta.getip()
                print(ip)
                if ip == nil then
                    print("Fail get ip...")
                else
                    print(string.format("Connected,IP is %s", ip))
                    t:unregister()
                    wifi.stopsmart()
                    dofile("ntp.lua")
                end
            end
        )
        mytimer:start()
    end
)
